{% extends "templates/atnet_base.html" %}

{% block csslink %}
{{ super() }}
<script src="/media/js/jquery.js"></script>

{% include 'templates/includes_datatable.html' %}
{% include 'templates/includes_jquery_ui.html' %}
<script src="/media/js/form_popup.js"></script>

<script type="text/javascript" charset="utf-8">
$(document).ready(function() {
	$('#keys').dataTable({
		"bPaginate": false,
		"bLengthChange": false,
		"bFilter": true,
		"bSort": true,
		"bInfo": false,
		"bAutoWidth": false,
		"oLanguage": {
			"sUrl": "/media/js/dataTables.{{ app_user.lang }}.txt"
		},
		"bProcessing": true,
		"sAjaxSource": "{{ uri_for('parametrage_cles', imm_id=immeuble.key().id(), command='list_json') }}",
		"fnRowCallback": function( nRow, aData, iDisplayIndex ) {
			$('td:eq(3)', nRow).html('<a href="javascript:void(0);" id="' + aData[3] + '">{{ _("Edit") }}</a>');
		},
	});
	
	$('#add-ck').live('click', function(){
		$(this).LaunchPopup({
			TableId: '#keys',
			DivId: '#dialog-form',
			FormId: '#generated-form',
			UrlForm: "{{ uri_for('parametrage_cles', imm_id=immeuble.key().id(), command='add') }}",
			Mode: 'add',
			Title: '{{ _("Add charges key") }}',
			UrlReturn: "{{ uri_for('parametrage_cles', imm_id=immeuble.key().id(), command='list') }}"
		})
	});
	
	$('#keys tbody tr a').live('click', function(e) {
		$(this).LaunchPopup({
			TableId: '#keys',
			DivId: '#dialog-form',
			FormId: '#generated-form',
			UrlForm: "{{ uri_for('parametrage_cles', imm_id=immeuble.key().id(), command='edit') }}" + e.target.id + "/",
			Mode: 'edit',
			Title: '{{ _("Edit charges key") }}',
			UrlReturn: "{{ uri_for('parametrage_cles', imm_id=immeuble.key().id(), command='list') }}"
		})
	});
});
</script>
{% endblock %}

{% block title %} 
	{{ title }}
{% endblock %}

{% block header %}
{{ header }}
{% endblock %}

{% block login%}
{% if show_login %}
{{ super() }}
{% endif %}
{% endblock%}

{% block navigation %}
{% if not show_login %}
{{ super() }}
{% endif %}
{% endblock %}

{% block page_name %}
{{ content_header }}
{% endblock %}

{% block section_menu %}
{% include 'templates/includes_parametrage_menu.html' %}
{% endblock %}

{% block main_content %}
<p>
	<p><a href="javascript:void(0);" id="add-ck">{{ _('Add charge key') }}</a> ||
	<a href="{{ uri_for('parametrage_cles', imm_id=immeuble.key().id(), command='predefine') }}">{{ _('Set or restore default list of charges keys') }}</a>  </p>
	<br /><br />
	<div id="demo">
	<table cellpadding="0" cellspacing="0" border="0" class="display" id="keys" width="100%">
		<thead>
			<tr>
				<th>{{ _(fields.code) }}</th>
				<th>{{ _(fields.name) }}</th>
				<th>{{ _(fields.th_tantiem_sum) }}</th>
				<th></th>
			</tr>
		</thead>
		<tbody>
		</tbody>
		<tfoot>
			<tr>
				<th>{{ _(fields.code) }}</th>
				<th>{{ _(fields.name) }}</th>
				<th>{{ _(fields.th_tantiem_sum) }}</th>
				<th></th>
			</tr>
		</tfoot>
	</table>
	</div>
	{% include 'templates/includes_popup_form.html' %}
</p>			
{% endblock %}
